<template>
	<view class="container">
		<!-- #ifdef MP-WEIXIN -->
		<authorize></authorize>
		<!-- #endif -->
		<view class="">
			<view class="l-box-pf-t c-bg-f w100 o-plr">
				<view class="o-ptb-s l-fjb" style="height: 90rpx;">
					<view class="l-fjb u-b c-bg-f o-mr l-f3 h100">
						<view class="l-fcc l-f1 h100" @click="scanCode()">
							<u-icon size="48" name="/static/images/scanCode.png"></u-icon>
						</view>
						<view class="o-pr l-f3">
							<u-input v-model="location" placeholder="请输入电梯安装地址" :type="type" :border="border" />
						</view>
					</view>
					<view @click="search()" class="c-bg-f l-f1 l-fcc u-b h100 c-t7">搜索</view>
				</view>
			</view>
			
			<view style="height: 90rpx"></view>
			
			<view v-if="list&&list.records.length>0" class="o-plr">
				<view v-for="(item,index) in list.records" :key="index" class="o-plr c-bg-f u-b l-fc o-ptb c-r-l o-mt">
					<view class="l-fa c-line-12 o-pr">
						<view class="">
							<text class="c-ws">电梯注册代码：</text>
							{{item.eleCode}}
						</view>
						<view class="">
							<text class="c-ws">安装地址：</text>
							{{item.location}}
						</view>
						<view class="">
							<text class="c-ws">详细位置：</text>
							{{item.locationDetail}}
						</view>
					</view>
					<view class="">
						<button @click="toProposal(item)" class="c-ws" style="padding: 0 30rpx;" type="default" size="mini">投诉建议</button>
					</view>
				</view>
				<load-more :status="status"></load-more>
			</view>
			
			<view v-else>
				<empty></empty>
			</view>
			
		</view>
	</view>
</template>

<script>
	import empty from '@/components/empty.vue'
	import loadMore from '@/components/load-more.vue'
	export default {
		data() {
			return {
				location: '德瑞花园',
				type: 'text',
				border: false,
				current:1,
				size:10,
				status: 'loadmore'
			}
		},
		components:{empty, loadMore},
		computed:{
			list: vm => vm.$store.getters.complainList,
			
		},
		onLoad() {
			this.getList()
		},
		methods: {
			// 扫码
			scanCode() {
				uni.scanCode({
				    onlyFromCamera: true, //允许通过相机扫码
				    success: (res) => {
				        console.log('条码类型：' + res.scanType);
				        console.log('条码内容：' + res.result);
						// this.$Function.LinkTo(`/pages/work/repair/recordDetails?eleId=${res.result}`)
				    }
				});
			},
			// 搜索
			search() {
				this.getList()
			},
			toProposal(e) {
				let {id,eleCode,location,locationDetail} = e;
				let data = {
					id,eleCode,location,locationDetail
				}
				this.$Function.LinkTo(`/pages/complaint/proposal?data=${JSON.stringify(data)}`)
			},
			
			getList() {
				this.$store.dispatch('get_ComplainList',{userId: uni.getStorageSync('userId'),location:this.location,current: this.current, size: this.size
				})
			}
			
		}
	}
</script>

<style>
	
</style>
